﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Logic;

namespace web_CategoryMS.View
{
    public partial class FS0001 : System.Web.UI.Page
    {
        FS0001Logic fS0001Logic = new FS0001Logic();
        #region 初始化事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    DataTable dt = fS0001Logic.Search();
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        dgv.DataSource = dt;
                        dgv.DataBind();
                    }
                    else
                    {
                        BindNullDT();
                    }
                }
                catch (Exception ex)
                {

                }
                
            }
        }
        #endregion

        #region 绑定空行
        private void BindNullDT()
        {
            DataTable dt = new DataTable();
            dt.Rows.Clear();
            dt.Columns.Add("iAutoID");
            dt.Columns.Add("vcRequirementNo");
            dt.Columns.Add("vcRequirementName");
            dt.Columns.Add("vcRequirementDescription");
            DataRow dr = dt.NewRow();
            dr["iAutoID"] = "";
            dr["vcRequirementNo"] = "";
            dr["vcRequirementName"] = "";
            dr["vcRequirementDescription"] = "";
            dt.Rows.Add(dr);
            dgv.DataSource = dt;
            dgv.DataBind();
        }
        #endregion

        #region 行绑定事件
        protected void dgv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if (string.IsNullOrEmpty(e.Row.Cells[0].Text) || e.Row.Cells[0].Text == "&nbsp;")
                    {
                        return;
                    }
                    e.Row.Cells[2].Attributes.Add("onclick", "return OpenImage('" + e.Row.Cells[0].Text + "');");
                }
            }
            catch (Exception ex)
            {

            }
        }
        #endregion
    }
}